<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-28 10:14:16
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /special/application/common/service/module_manage/hgshield/IpsOriginalRule.php
 */

namespace app\common\service;


use think\Db;

class IpsOriginalRule
{
    /**
     * @name 列表
     * @param $hostId
     * @param $params
     * @return array
     * @author wx
     * @date 2019/11/21 10:58
     */
    public function list($hostId, $params)
    {
        $db = Db::name('ips_original_rule')->where('host_id',$hostId);
        
        if(isset($params['rule']) && !empty($params['rule'])){
            $db->where('rule','like','%'.$params['rule'].'%');
        }

        $list = $db->order('id desc')->paginate()->toArray();

        return $list;
    }

    /**
     * @name
     * @param $condition
     * @param $updateData
     * @return int|string
     * @author wx
     * @date 2019/11/21 10:53
     */
    public function modify($condition, $updateData)
    {
        return Db::name('ips_original_rule')->where($condition)->update($updateData);
    }

    /**
     * @name 删除
     * @param $condition
     * @return int
     * @author wx
     * @date 2019/11/21 10:58
     */
    public function del($condition)
    {
        return Db::name('ips_original_rule')->where($condition)->delete();
    }
    
    /**
     * @name: 查找
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-12-13 11:32:11
     */
    public function checkRequestData ($hostId, $ruleId)
    {
        $return = Db::name('ips_original_rule')->where('host_id', $hostId)->whereIn('id', $ruleId)->select();

        return $return;
    }
}